package com.ruoyi.common.utils.redBag;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * @author Dale Mao    ---多多 Email:453918229@qq.com
 * @description RamdomMoneyUtils
 * @date 2020-11-09 01:05
 */
public class RamdomMoneyUtils  {

    public static Map<String,Object> getMinMoney(double money, int start, int end) {

        BigDecimal bigDecimal = new BigDecimal(money);

        Random random = new Random();
        double b=random.nextDouble();
        System.out.println(b);
       double s =start + ((end - start) *b);//min + ((max - min) *
        System.out.println(s);
        double c=RedPaperBreakUpAlg.toFixed(s,2);
        System.out.println(c);
        BigDecimal minMoney =bigDecimal.subtract(new BigDecimal(c)).setScale(2,RoundingMode.HALF_UP);
        Map map = new HashMap();
        map.put("disMoney",c);
        map.put("getMoney",minMoney);
        return map;
    }



    public static void main(String[] args ){
           Map lossMoney= getMinMoney(100,4,6);
           Object o=lossMoney.get("disMoney");
             Object os=lossMoney.get("getMoney");
           System.out.println(o);
        System.out.println(os);
    }
}
